package cn.zwx.infra.svc;

import cn.zwx.base.entity.ResponseEntity;
import cn.zwx.base.exception.BizWrapException;
import cn.zwx.base.utils.PageUtil;
import cn.zwx.infra.svc.dto.SmsChannelPageDTO;
import cn.zwx.infra.svc.dto.SmsChannelSaveDTO;
import cn.zwx.infra.svc.dto.SmsChannelUpdateDTO;
import cn.zwx.infra.svc.fallback.SmsChannelApiFallback;
import cn.zwx.infra.svc.vo.SmsChannelSimpleVO;
import cn.zwx.infra.svc.vo.SmsChannelVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author zhangwenxue
 */
@FeignClient(name = "member-svc",path = "/infra/sms")
public interface SmsChannelApi extends FallbackFactory<SmsChannelApiFallback> {
    @PostMapping
    SmsChannelApiFallback create(Throwable cause);


    /**
     *  创建短信渠道借口
     * @param dto dto
     * @return ResponseEntity
     */
    @PostMapping("/create")
    @ApiOperation("创建短信渠道借口")
    ResponseEntity<Long> createSmsChannel(@Valid @RequestBody SmsChannelSaveDTO dto);

    /**
     * 更新短信渠道
     * @param dto dto
     * @return ResponseEntity
     * @throws BizWrapException BizWrapException
     */
    @PutMapping("/update")
    @ApiOperation("更新短信渠道")
    ResponseEntity<Boolean> updateSmsChannel(@Valid @RequestBody SmsChannelUpdateDTO dto) throws BizWrapException;

    /**
     * 删除短信渠道
     * @param id 编号
     * @return  ResponseEntity
     * @throws BizWrapException BizWrapException
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除短信渠道")
    ResponseEntity<Boolean> deleteSmsChannel(@Valid@NotNull(message = "编号不能为空")
                                             @ApiParam(value = "编号",required = true)
                                             @RequestParam("id") Long id)  throws BizWrapException;

    /**
     * 获得短信渠道
     * @param id 编号
     * @return  ResponseEntity
     */
    @GetMapping("/get")
    @ApiOperation( "获得短信渠道")
    ResponseEntity<SmsChannelVO> getSmsChannel(@Valid@NotNull(message = "编号不能为空")
                                                   @ApiParam(value = "编号",required = true)

                                                   @RequestParam("id") Long id) ;

    /**
     * 获得短信渠道分页
     * @param dto dto
     * @return  ResponseEntity
     */
    @GetMapping("/page")
    @ApiOperation("获得短信渠道分页")
    ResponseEntity<PageUtil<SmsChannelVO>> getSmsChannelPage(@Valid SmsChannelPageDTO dto);


    /**
     * 获得短信渠道精简列表
     * @return  ResponseEntity
     */
    @GetMapping({"/list-all-simple", "/simple-list"})
    @ApiOperation("获得短信渠道精简列表 包含被禁用的短信渠道")
    ResponseEntity<List<SmsChannelSimpleVO>> getSimpleSmsChannelList();
}
